package com.example.activemq;

import javax.jms.Queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * Project:spring-boot-activemq
 * <p>
 * Title:MessageProducer.java
 * <p>
 * Description:
 * <p>
 * Copyrigth:Jiang Software LTD.co Copyright (c) 2021
 * <p>
 * 
 * @version 1.0
 * @since 1.8
 * @author jiang
 * @history 2021 jiang create
 */

@Service
public class MessageProducer {

	// 消息发送模板
	@Autowired
	private JmsMessagingTemplate jmsMessagingTemplate;

	// 注入队列
	@Autowired
	private Queue queue;

	/**
	 * 发送消息
	 */
	public void send(String msg) {
		this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
	}

}